
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false" language="java" %>
<!DOCTYPE html>
<head>
    <title>员工登录</title>
    <link rel="stylesheet" href="resources/css/index.css">
    <link rel="stylesheet" href="resources/layui/css/layui.css">
</head>
<body>
<div class="main">
    <div class="header">
        <div class="header-center fl">
            <div class="header-title">
                员工登录
            </div>
            <div class="header-img"></div>
        </div>
        <div class="header-bottom fl"></div>
    </div>
    <div class="content">
        <div class="content-left"></div>
        <div class="content-right">
            <div class="right-infp layui-form">
                <div class="right-infp-name">
                    <input type="text" name="username" lay-verType="tips" lay-verify="required" lay-reqText="用户名不能为空"
                           placeholder="用户名" autocomplete="off" value="admin">
                </div>
                <div class="right-infp-name">
                    <input type="text" name="password" lay-verType="tips" lay-verify="required" lay-reqText="密码不能为空"
                           placeholder="密码" autocomplete="off" value="admin">
                </div>
                <div class="right-infp-name" style="width: 120px">
                    <input type="text" lay-verify="required" lay-verType="tips" lay-reqText="验证码不能为空" name="checkCode"
                           placeholder="验证码" autocomplete="off">
                    <img src="checkCode.do" id="checkCodeImg"
                         style="height: 0.5rem ;width: 120px ;position: relative;left:130px;"/>
                </div>
                <div class="right-infp-btn">
                    <button class="btn" type="button" lay-submit lay-filter="subBtnFilter">登录</button>
                </div>
            </div>
        </div>
    </div>
</div>

<script src="resources/layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer'],function () {
        let form = layui.form;
        let $ = layui.jquery;
        let layer = layui.layer;
        /**
         * 表单提交的监听
         */
        form.on("submit(subBtnFilter)",function (d) {
            //获取表单数据
            let formData = d.field;
            $.post("user.do?service=login",formData,function (rs) {
                //登录失败 展示原因
                if (rs.code!=200){
                    layer.msg(rs.msg);
                    return false;
                }
                //登录成功 进行页面的跳转
                location.href = "page.do?service=main"
            })
            return false;
        });
        //点击刷新验证码
        $("#checkCodeImg").click(function () {
            $(this).attr("src","checkCode.do?"+new Date());
        });
        var whei = $(window).width()
        $("html").css({ fontSize: whei / 24 });
        $(window).resize(function () {
            var whei = $(window).width();
            $("html").css({ fontSize: whei /24})
        });
    });
</script>
</body>
</html>
